package com.own.business.login.phone.core.form;

import com.own.component.common.exception.BusinessSimpleException;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * PhoneCodeForm
 *
 * @author chenxueli
 * @date 2023-06-25 21:51:00
 */
@Data
public class PhoneCodeForm implements Serializable {

    @Schema(title = "手机号")
    private String phone;

    @Schema(title = "加密秘钥字段key")
    private String key;

    @Schema(title = "账号类型 1=普通用户 2=管理员", hidden = true)
    private Integer type;

    public void init() {
        if (type == null) {
            type = 1;
        }
    }

    public void check() {
        init();
        if (StringUtils.isBlank(phone)) {
            throw new BusinessSimpleException("手机号不能为空");
        }
    }

}
